﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace WorkNodeFramework
{
    public class WorkNodeTable:Table
    {
        public WorkNodeTable(DataProvider provider, string tableName)
            : base(provider, tableName) 
        {
                Column idColumn = new Column(this, IDColumnName);
                idColumn.SqlDbType = SqlDbType.UniqueIdentifier;
                idColumn.IsPrimaryKey = true;
                Columns.Add(idColumn);

                Column nameColumn = new Column(this, NameColumnName);
                nameColumn.SqlDbType = SqlDbType.NVarChar;
                nameColumn.Size = 100;
                nameColumn.IsNullable = false;
                Columns.Add(nameColumn);

                Column pathColumn = new Column(this, PathColumnName);
                pathColumn.SqlDbType = SqlDbType.NVarChar;
                pathColumn.Size = 200;
                pathColumn.IsNullable = false;
                Columns.Add(pathColumn);

                Column typeColumn = new Column(this, TypeColumnName);
                typeColumn.SqlDbType = SqlDbType.VarChar;
                typeColumn.Size = 100;
                typeColumn.IsNullable = false;
                Columns.Add(typeColumn);

                Column attrColumn = new Column(this, AtrributesColumnName);
                attrColumn.SqlDbType = SqlDbType.Int;
                attrColumn.IsNullable = false;
                Columns.Add(attrColumn);

                Column parentIDColumn = new Column(this, ParentIDColumnName);
                parentIDColumn.SqlDbType = SqlDbType.UniqueIdentifier;
                parentIDColumn.IsNullable = true;
                Columns.Add(parentIDColumn);

                Column openDateColumn = new Column(this, OpenDateColumnName);
                openDateColumn.SqlDbType = SqlDbType.DateTime;
                openDateColumn.IsNullable = false;
                Columns.Add(openDateColumn);

                Column lastDateColumn = new Column(this, LastDateColumnName);
                lastDateColumn.SqlDbType = SqlDbType.DateTime;
                lastDateColumn.IsNullable = true;
                Columns.Add(lastDateColumn);
        }

        public const string IDColumnName = "ID";
        public const string NameColumnName="Name";
        public const string PathColumnName="Path";
        public const string TypeColumnName="Type";
        public const string AtrributesColumnName = "Attributes";
        public const string ParentIDColumnName = "ParentID";
        public const string OpenDateColumnName = "OpenDate";
        public const string LastDateColumnName = "LastDate";

        public Column IDColumn {
            get {
                return base[IDColumnName];
            }
        }

        public Column NameColumn {
            get {
                return base[NameColumnName];
            }
        }

        public Column PathColumn {
            get {
                return base[PathColumnName];
            }
        }

        public Column TypeColumn {
            get {
                return base[TypeColumnName];
            }
        }

        public Column AttributesColumn {
            get {
                return base[AtrributesColumnName];
            }
        }

        public Column ParentIDColumn {
            get {
                return base[ParentIDColumnName];
            }
        }

        public Column OpenDateColumn
        {
            get
            {
                return base[OpenDateColumnName];
            }
        }

        public Column LastDateColumn
        {
            get
            {
                return base[LastDateColumnName];
            }
        }
    }

    public class WorkNodePropertiesTable : Table {
        public WorkNodePropertiesTable(DataProvider provider, string tableName)
            : base(provider, tableName) 
        {
            Column workNodeIDColumn = new Column(this, WorkNodeIDColumnName);
            workNodeIDColumn.IsPrimaryKey = true;
            workNodeIDColumn.SqlDbType = SqlDbType.UniqueIdentifier;
            workNodeIDColumn.IsNullable = false;
            Columns.Add(workNodeIDColumn);

            Column nameColumn = new Column(this, NameColumnName);
            nameColumn.IsPrimaryKey = true;
            nameColumn.SqlDbType = SqlDbType.VarChar;
            nameColumn.Size = 100;
            nameColumn.IsNullable = false;
            Columns.Add(nameColumn);

            Column contentColumn = new Column(this, ContentColumnName);
            contentColumn.SqlDbType = SqlDbType.NText;
            contentColumn.IsNullable = true;
            Columns.Add(contentColumn);

            Column openDateColumn = new Column(this, OpenDateColumnName);
            openDateColumn.SqlDbType = SqlDbType.DateTime;
            openDateColumn.IsNullable = false;
            Columns.Add(openDateColumn);

            Column lastDateColumn = new Column(this, LastDateColumnName);
            lastDateColumn.SqlDbType = SqlDbType.DateTime;
            lastDateColumn.IsNullable = true;
            Columns.Add(lastDateColumn);
        }

        public const string WorkNodeIDColumnName = "WorkNodeID";
        public const string NameColumnName = "Name";
        public const string ContentColumnName = "Content";
        public const string OpenDateColumnName = "OpenDate";
        public const string LastDateColumnName = "LastDate";

        public Column WorkNodeIDColumn {
            get {
                return base[WorkNodeIDColumnName];
            }
        }

        public Column NameColumn {
            get {
                return base[NameColumnName];
            }
        }

        public Column ContentColumn {
            get {
                return base[ContentColumnName];
            }
        }

        public Column OpenDateColumn
        {
            get
            {
                return base[OpenDateColumnName];
            }
        }

        public Column LastDateColumn
        {
            get
            {
                return base[LastDateColumnName];
            }
        }
    }

    public class WorkNodeLangPropertiesTable : WorkNodePropertiesTable {
        public WorkNodeLangPropertiesTable(DataProvider provider, string tableName)
            : base(provider, tableName) 
        {
            Column langCol = new Column(this, LangIDColumnName);
            langCol.IsPrimaryKey = true;
            langCol.SqlDbType = SqlDbType.VarChar;
            langCol.Size = 5;
            langCol.IsNullable = false;
            Columns.Add(langCol);
        }
        public const string LangIDColumnName = "LangID";

        public Column LangIDColumn {
            get {
                return base[LangIDColumnName];
            }
        }
    }
}
